//
//  tabTwoViewController.m
//  iospro
//
//  Created by yons on 27.4.21.
//

#import "tabTwoViewController.h"
#import <JXCategoryView/JXCategoryView.h>
#import "AAViewController.h"

@interface tabTwoViewController ()<JXCategoryListContainerViewDelegate>

@property (nonatomic, strong) JXCategoryTitleView *myCategoryView;

@end

@implementation tabTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    
    [self drawTopSegmentView];
    [self.view addSubview:self.listContainerView];
}

-(void)drawTopSegmentView{
    
        self.titles = @[@"建言献策",@"员工维权",@"外部维权"];
    
        self.myCategoryView.titles = self.titles;
        self.myCategoryView.frame = CGRectMake(0, 0,300, 30);
        self.myCategoryView.titles = self.titles;
        self.myCategoryView.cellSpacing = 0;
        self.myCategoryView.titleColor = [UIColor redColor];
        self.myCategoryView.titleSelectedColor = [UIColor whiteColor];

        JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
        backgroundView.indicatorHeight = 30;
        backgroundView.indicatorWidthIncrement = 20;
        backgroundView.indicatorColor = [UIColor redColor];
        self.myCategoryView.indicators = @[backgroundView];
    
        [self.myCategoryView removeFromSuperview];
        self.navigationItem.titleView = self.myCategoryView;
    
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    self.myCategoryView.frame = CGRectMake(0,0,300, 30);
}

- (JXCategoryTitleView *)myCategoryView {
    return (JXCategoryTitleView *)self.categoryView;
}

- (CGFloat)preferredCategoryViewHeight {
    return 0;
}

- (JXCategoryBaseView *)preferredCategoryView {
    return [[JXCategoryTitleView alloc] init];
}

#pragma mark - JXCategoryListContainerViewDelegate

// 返回列表的数量
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return self.titles.count;
}

// 返回各个列表菜单下的实例，该实例需要遵守并实现 <JXCategoryListContentViewDelegate> 协议
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    
    AAViewController *list = [[AAViewController alloc] init];
    if (index == 0) {
        list.titles = @[@"香蕉", @"苹果", @"荔枝"];
    }else if(index == 1) {
        list.titles = @[@"冰淇淋", @"可乐"];
    }else if (index == 2) {
        list.titles = @[@"火锅", @"砂锅", @"干锅"];
    }
    return list;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
